.TH SPI-CONFIG "1" "August 2014" "SPI-tools" "User Commands"
.SH NAME
spi-config \- set or query SPI configuration.
.SH SYNOPSIS
.B spi-config
\fIoptions\fR...
.SH DESCRIPTION
.PP
Set or query the configuration of a SPI port.
.TP
\fB\-d\fR, \fB\-\-device\fR=\fIDEVICE\fR
use the given Linux spidev character device.
.TP
\fB\-q\fR, \fB\-\-query\fR
print the current configuration.
.TP
\fB\-m\fR, \fB\-\-mode\fR=\fI[0-3]\fR
set the spi mode (see SPI MODES below).
.TP
\fB\-l\fR, \fB\-\-lsb\fR=\fI{0,1}\fR
set LSB first (1) or MSB first (0).
.TP
\fB\-b\fR, \fB\-\-bits\fR=\fI[7...]\fR
set the number of bits per word.
.TP
\fB\-s\fR, \fB\-\-speed\fR=\fIFREQUENCY\fR
set clock frequency (in Hz).
.TP
\fB\-r\fR, \fB\-\-spirdy\fR=\fI{0,1}\fR
set the SPI READY mode flag.
.TP
\fB\-w\fR, \fB\-\-wait
block, keeping the file descriptor open. See \fBWAIT OPTION\fR below.
.TP
\fB\-h\fR, \fB\-\-help\fR
display the help screen and exit.
.TP
\fB\-v\fR, \fB\-\-version\fR
display the version number and exit.

.SS "SPI MODES"
.TP
mode 0
low idle level, sample on leading edge.
.TP
mode 1
low idle level, sample on trailing edge.
.TP
mode 2
high idle level, sample on leading edge.
.TP
mode 3
high idle level, sample on trailing edge.

.SS "WAIT OPTION"
On some platforms, the speed is reset to a default value when the file descriptor is closed.
To avoid this, one can use the \fB\-w\fR option that keeps the file descriptor open. See also
last example below.
.SH EXAMPLES
.TP
Get help:
$ \fBspi\-config \-h\fR
.TP
Query current configuration:
$ \fBspi\-config \-\-device=/dev/spidev0.0 \-q\fR
.TP
Change clock frequency to 1 MHz:
$ \fBspi\-config \-\-device=/dev/spidev0.0 \-\-speed=1000000\fR
.TP
Set a configuration and keep the device open:
$ \fBspi\-config \-\-wait \-\-speed=1000000\fR & PID=$!
.TP
Close device previously open:
$ \fBkill\fP $PID
.SH AUTHOR
Written by Christophe BLAESS <https://www.blaess.fr/christophe>.
.SH "REPORTING BUGS"
.br
Github home page: <https://github.com/cpb-/spi-tools.git>
.SH COPYRIGHT
Copyright \(co 2014 Christophe Blaess.
.br
Licensed under GPLv2 <http://gnu.org/licenses/gpl.html>.
.br
This is free software: you are free to change and redistribute it.
.br
There is NO WARRANTY, to the extent permitted by law.
